"use strict";

module.exports = {
  // 在执行数据库升级时调用的函数，创建 t_funcs 表
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, DATE, STRING, CHAR, UUID,UUIDV4 } = Sequelize;
    await queryInterface.createTable("t_func", {
      id: {type: UUID, primaryKey: true, allowNull: false, defaultValue: UUIDV4},
      parent_id: { type: UUID, allowNull: true },
      name: { type: STRING(50), allowNull: false },
      level: { type: CHAR(3), allowNull: false, defaultValue:"000" },
      pattern: { type: STRING(50), allowNull: true },
      icon: { type: STRING(50), allowNull: true },
      status: { type: CHAR(3), allowNull: true, defaultValue:"000" },
      remark: { type: STRING(200), allowNull: true },
      create_user_id: { type: UUID, allowNull: true },
      modify_user_id: { type: UUID, allowNull: true },
      create_time: { type: DATE, allowNull: false },
      modify_time: { type:DATE, allowNull: false }
    });
  },
  // 在执行数据库降级时调用的函数，删除 t_funcs 表
  down: async queryInterface => {
    await queryInterface.dropTable("t_func");
  }
};
